package com.huibei.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.huibei.pojo.City;
import com.huibei.pojo.House;
import com.huibei.service.ICityService;
import com.huibei.util.ReturnData;
import com.huibei.util.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.sql.Wrapper;
import java.util.List;
import java.util.Map;

@RestController
public class CityController {

    @Resource
    private ICityService cityService;

    @RequestMapping(value = "/getCity", method = RequestMethod.POST)
    public Object getCityByName(@RequestParam Map<String, Object> map){
        System.out.println(map);
        System.out.println(map);

        QueryWrapper<City> wrap = new QueryWrapper<>();
        wrap.eq("CITY_NAME", map.get("cityName"));
        Map map1 = cityService.getMap(wrap);
        System.out.println(map1);
        if(map1.containsKey("CITY_NAME")){
            return new ReturnData(StatusCode.REQUEST_SUCCESS, map1, "查询城市数据成功");
        }else{
            return new ReturnData(StatusCode.DATA_NULL, false, "暂无城市数据");
        }
    }


}
